﻿using System.Linq;
using System.Xml.Linq;

namespace TPOJ.CoreWF
{
    public class Language
    {
        private string name;

        public Language(string name)
        {
            XDocument compilers = XDocument.Load(@"C:\Users\lehope\Documents\Visual Studio 2010\Projects\TPOJ\TPOJ.Web\Config\Compilers.config");
            var query = from c in compilers.Elements("Compilers").Elements("Compiler")
                        where c.Element("Name").Value.Equals(name)
                        select c;
            var currentCompiler = query.First();

            this.CompileCommandLine = currentCompiler.Element("CompileCommand").Value;
            this.RunCommandLine = currentCompiler.Element("RunCommand").Value;
            this.TimeFix = int.Parse(currentCompiler.Element("TimeFix").Value);
            this.MemoryFix = int.Parse(currentCompiler.Element("MemoryFix").Value);
            this.TimeFactor = int.Parse(currentCompiler.Element("TimeFactor").Value);
            this.name = name;
        }

        public string CompileCommandLine { get; set; }
        public string RunCommandLine { get; set; }
        public int TimeFix { get; set; }
        public int MemoryFix { get; set; }
        public int TimeFactor { get; set; }
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }
}
